import requests
from fake_useragent import UserAgent
import pymongo
client = pymongo.MongoClient()
client.drop_database("bilibili")
db = client.get_database("bilibili")
collection = db.get_collection("fanju")

ua = UserAgent()

for page in range(1, 198):
	print(f"正在爬取第{page}页")
	res = requests.get(f'https://api.bilibili.com/pgc/season/index/result?st=1&order=3&season_version=-1&spoken_language_type=-1&area=-1&is_finish=-1&copyright=-1&season_status=-1&season_month=-1&year=-1&style_id=-1&sort=0&page={page}&season_type=1&pagesize=20&type=1', headers={
		"user-agent": ua.random
	})
	# print(res.json())
	collection.insert_many(res.json()['data']['list'])

client.close()


